package util;

import javax.media.j3d.Transform3D;
import javax.vecmath.Vector3f;

public class Transform
{

  private Transform3D getCompoundTransform()
  { Transform3D translate=new Transform3D();
    Transform3D scale=new Transform3D();
    Transform3D rotateX=new Transform3D();
    Transform3D rotateY=new Transform3D();
    Transform3D rotateZ=new Transform3D();
    translate.set(new Vector3f(-1.0f, 0.0f, 0.0f)); // Move 1m til venstre langs x-akse
    rotateX.rotX(Math.PI/8); // Clockwise rotation in radians
    rotateY.rotY(Math.PI/8); // Clockwise rotation in radians
    rotateZ.rotZ(Math.PI/8); // Clockwise rotation in radians
    scale.setScale(0.001);//(0.4);
    Transform3D t=new Transform3D(); // Initates to unity
    t.set(translate);
//  t.mul(scale);
    t.mul(rotateX);
    t.mul(rotateY);
//  t.mul(rotateZ);
    return(t);
  }

  public static Transform3D move(double dx,double dy,double dz)
  { return(move(new Transform3D(),dx,dy,dz)); }

  public static Transform3D move(Transform3D t,double dx,double dy,double dz)
  { Transform3D translate=new Transform3D();
    translate.set(new Vector3f((float)dx,(float)dy,(float)dz));
    t.mul(translate);
    return(t);
  }

  public static Transform3D rotate(double rx,double ry,double rz)
  { return(rotate(new Transform3D(),rx,ry,rz)); }

  public static Transform3D rotate(Transform3D t,double rx,double ry,double rz)
  { Transform3D rotateX=new Transform3D();
    Transform3D rotateY=new Transform3D();
    Transform3D rotateZ=new Transform3D();
    rotateX.rotX(rx); // Clockwise rotation in radians
    rotateY.rotY(ry); // Clockwise rotation in radians
    rotateZ.rotZ(rz); // Clockwise rotation in radians
    t.mul(rotateX);
    t.mul(rotateY);
    t.mul(rotateZ);
    return(t);
  }
}
